﻿package me.weijing.common;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Environment;

public class CommonApplication extends Application {
    private static CommonApplication mInstance = null;
    public final String UUIDCachePath = Environment.getExternalStorageDirectory().getPath() + "+//weijing//user.txt";
    /** Preference key for account username. */
    public static final String ACCOUNT_USERNAME_KEY = "account_username";
    /** Preference key for account password. */
    public static final String ACCOUNT_PASSWORD_KEY = "account_password";
    /** Preference key set to true if using an Android account . */
    public static final String USE_SYSTEM_ACCOUNT_KEY = "use_system_account";

    /** Preference key for Android account type . */
    public static final String ACCOUNT_SYSTEM_TYPE_KEY = "account_system_type";

    /** Preference key set to true if using specific server details. */
    public static final String ACCOUNT_SPECIFIC_SERVER_KEY = "account_specific_server";

    /** Preference key for specific server hostname. */
    public static final String ACCOUNT_SPECIFIC_SERVER_HOST_KEY = "account_specific_server_host";

    /** Preference key for specific server port. */
    public static final String ACCOUNT_SPECIFIC_SERVER_PORT_KEY = "account_specific_server_port";

    /** Preference key for status (available, busy, away, ...). */
    public static final String STATUS_KEY = "status";
    /** Preference key for status message. */
    public static final String STATUS_TEXT_KEY = "status_text";
    /** Preference key for connection resource . */
    public static final String CONNECTION_RESOURCE_KEY = "connection_resource";
    /** Preference key for connection priority. */
    public static final String CONNECTION_PRIORITY_KEY = "connection_priority";
    /** Preference key for the use of a proxy. */
    public static final String PROXY_USE_KEY = "proxy_use";
    /** Preference key for the type of proxy. */
    public static final String PROXY_TYPE_KEY = "proxy_type";
    /** Preference key for the proxy server. */
    public static final String PROXY_SERVER_KEY = "proxy_server";
    /** Preference key for the proxy port. */
    public static final String PROXY_PORT_KEY = "proxy_port";
    /** Preference key for the proxy username. */
    public static final String PROXY_USERNAME_KEY = "proxy_username";
    /** Preference key for the proxy password. */
    public static final String PROXY_PASSWORD_KEY = "proxy_password";
    /** Preference key for vibrate on notification. */
    public static final String NOTIFICATION_VIBRATE_KEY = "notification_vibrate";
    /** Preference key for notification sound. */
    public static final String NOTIFICATION_SOUND_KEY = "notification_sound";
    /** Preference key for smack debugging. */
    public static final String SMACK_DEBUG_KEY = "smack_debug";
    /** Preference key for full Jid for login. */
    public static final String FULL_JID_LOGIN_KEY = "full_jid_login";
    /** Preference key for display offline contact. */
    public static final String SHOW_OFFLINE_CONTACTS_KEY = "show_offline_contacts";
    /** Preference key for hide the groups. */
    public static final String HIDE_GROUPS_KEY = "hide_groups";
    /** Preference key for auto away enable. */
    public static final String USE_AUTO_AWAY_KEY = "use_auto_away";
    /** Preference key for auto away message. */
    public static final String AUTO_AWAY_MSG_KEY = "auto_away_msg";
    /** Preference key for compact chat ui. */
    public static final String USE_COMPACT_CHAT_UI_KEY = "use_compact_chat_ui";
    /** Preference key for history path on the SDCard. */
    public static final String CHAT_HISTORY_KEY = "settings_chat_history_path";
    /** Preference key to show the jid in the contact list. */
    public static final String SHOW_JID = "show_jid";
    public static final String UPDATE_APP_VERSION_CODE = "versionCode";
    public static final String UPDATE_APP_VERSION_PATH = "versionPath";
    public static boolean isShowNetworkChange = false;
    public static final int LOCAL_HTTP_URL = 1;
    public static final int SERVER_HTTP_URL = 2;
    public static final int LOCAL_OPENFIRE_URL = 1;
    public static final int SERVER_OPENFIRE_URL = 2;
    public static final int LOCAL_OPENFIRE_DOMAIN = 1;
    public static final int SERVER_OPENFIRE_DOMAIN = 2;

    public static final int LOCAL_MAP_POLICE = 1;
    public static final int SERVER_MAP_POLICE = 2;

    public static final int LOCAL_MAP_PEOPLE = 1;
    public static final int SERVER_MAP_PEOPLE = 2;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static CommonApplication getInstance() {
        return mInstance;
    }
    
    /**
     * 获取App安装包信息
     * @return
     */
    public PackageInfo getPackageInfo() {
        PackageInfo info = null;
        try { 
            info = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (NameNotFoundException e) {    
            e.printStackTrace(System.err);
        } 
        if(info == null) info = new PackageInfo();
        return info;
    }
    
}
